package com.leetcode.LC;

public class LC1154 {
    public int dayOfYear(String date) {

        String[] split = date.split("-");
        int year = Integer.valueOf(split[0]);
        int month = Integer.valueOf(split[1]);
        int day = Integer.valueOf(split[2]);
        int[] ints = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

        int sum = 0;
        for (int i = 1; i < month; i++) {
            sum += ints[i];
        }

        if (year % 400 == 0 || (year % 100 != 0 && year % 4 == 0)) {
            if (month > 2)
                sum += 1;
        }
        return sum + day;
    }

    public static void main(String[] args) {
        System.out.println(new LC1154().dayOfYear("2004-03-01"));
    }
}
